import React from 'react';
import { render } from 'react-dom';
import { Tools } from 'weaver-mobile';
import { HashRouter as Router } from 'react-router-dom';
import messagePageStore from './store';
import MessagePage from './components/message';

import './style';

const Root = () => {
  return(
    <Router>
      <div className="wm-home-entrance">
        <MessagePage heightSpace={10} />
      </div>
    </Router>
  )
}

const p1 = () => new Promise(rs => {
  Tools.getLocaleLabel('common', () => rs());
})

const p2 = () => new Promise(rs => {
  let defaultListParams = {
    id: 0,
    pagesize: 10,
    msgid: 0,
    mintime: 0,
    bizstate: '',
    current: 1
  }

  messagePageStore.getMessageData(defaultListParams, true, true, () => rs());
})

p1().then(() => {
  messagePageStore.getMsgTypeTabs().then(() => {
    p2().then(() => {
      render(<Root/>, document.getElementById('root'));
    })
  })
})